<template>
  <div>
    <div
      style="display: inline-block"
      v-for="(item, index) in arr"
      :key="index"
    >
      <!-- 选你爱我求和 -->
      <!--目标: 把用户选中的数字, 累计求和显示  -->
      <input type="checkbox" v-model="chooseNumber" :value="item" />{{ item }}
    </div>
    <br />
    你选中的数字累加的和为:{{ sumAll }}
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [9, 15, 19, 25, 29, 31, 48, 57, 62, 79, 87],
      chooseNumber: [],
    };
  },
  computed: {
    sumAll() {
      return this.chooseNumber.reduce((sum, val) => {
        return (sum += val);
      }, 0);
    },
  },
};
</script>

<style scoped></style>
